package org.wanho.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Author：汤小洋
 * Date：2023-04-20 13:56
 * Description：<描述>
 */
public class HelloServlet extends HttpServlet {

    // 会自动调用service方法
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("接收到用户的请求。。。。。。");

        // 设置响应的类型和字符集
        resp.setContentType("text/html;charset=utf8");

        // 获取打印输出流
        PrintWriter out = resp.getWriter();
        out.print("<h2 style='color:red;'>您的请求已接收到！</h2>");
        out.close();
    }
}
